﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;

namespace Yu.Cms.Config
{
    
    /// <summary>
    ///  轮显图片，聚合类
    /// </summary>
    public class AggregationFileManager : DefaultConfigFileManager
    {
       
     
        /// <summary>
        /// 配置文件所在路径
        /// </summary>
        public static string filename = null;

        /// <summary>
        /// 获取配置文件所在路径
        /// </summary>
        public new static string ConfigFilePath
        {
            get
            {
                if (filename == null)
                {
                    HttpContext context = HttpContext.Current;
                    if (context != null)
                    {
                        filename = context.Server.MapPath("~/Config/Aggregation.config");
                        if (!File.Exists(filename))
                        {
                            filename = context.Server.MapPath("/Config/Aggregation.config");
                        }
                    }
                    else
                    {
                        filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "~/Config/Aggregation.config");
                    }

                    if (!File.Exists(filename))
                    {
                        throw new Exception("发生错误: 虚拟目录或网站根目录下没有正确的Aggregation.config文件");
                    }
                }
                return filename;
            }
        }
    }
}
